<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>修改跟踪信息</title>
    <link rel="stylesheet" href="../../../../start/layui/css/layui.css" media="all">
    <style type="text/css">
        .layui-form-select .layui-input {
            padding-right: 0px;
            cursor: pointer;
        }
    </style>
    <script src="../../../../start/layui/layui.js"></script>
</head>
<body>
<form class="layui-form" action="">
    <div class="layui-row" style="padding-top: 10px">
        <label class="layui-form-label">运单号</label>
        <div class="layui-input-inline">
            <input type="text" id="waybill_id" disabled="disabled" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-row" style="padding-top: 10px">
        <label class="layui-form-label"> 跟踪时间：</label>
        <div class="layui-input-inline">
            <input type="date" name="datearrival" id="date"  placeholder="yyyy-MM-dd" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-row" style="padding-top: 10px">
        <label class="layui-form-label">跟踪类型</label>
        <div class="layui-input-inline">
            <select id="substationUnit">
                <option value="请选择">请选择</option>
                <option value="未装载">未装载</option>
                <option value="装车中">装车中</option>
                <option value="已发车">已发车</option>
                <option value="派送中">派送中</option>
                <option value="装车完毕">装车完毕</option>
                <option value="直接签收">直接签收</option>
            </select>
        </div>
    </div>
    <div class="layui-row" style="padding-top: 10px">
        <label class="layui-form-label">&nbsp;</label>
        <div class="layui-input-inline">
            <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
        </div>
    </div>
</form>
</body>
</html>
<script>
    layui.use(['form','jquery'], function() {
        var form = layui.form;
        var $ = layui.jquery;
        //显示网址
        var locationi=location.href;
        //根据下标截取字符串获得id
        var id=locationi.substring(locationi.indexOf("=")+1);
        if (id!=0){
            $.ajax({
                url: "../../../../XclTailAfterControllerGetTailafterByTailAfter",
                type: "post",
                data: {
                    id:id
                },
                dataType: "json",
                success: function (data) {
                    $('#waybill_id').val(data.waybillId)
                    $('#date').val(data.tailafterTime)
                    $("#substationUnit option[value='"+data.state+"']").attr("selected","selected");
                    //刷新
                    form.render("select");
                }
            })
        }
        //提交
        form.on('submit(formDemo)', function(data){
            $.ajax({
                url: "../../../../XclTailAfterControllerUpdateTailafter",
                type: "post",
                data: {
                    tailafter:id,
                    waybillId:$('#waybill_id').val(),
                    tailafterTime:$('#date').val(),
                    state:$('#substationUnit option:selected').val()
                },
                dataType: "text",
                success: function (data) {
                    var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                    parent.layer.close(index); //再执行关闭
                    layer.closeAll("iframe");//关闭iframe层
                    //修改成功后刷新父界面
                    window.parent.location.reload();
                }
            })
            return false;
        })
    })
</script>